﻿<#import "/common/function.ftl" as fn>
<@fn.header _title="">
<script type="text/javascript" src="${base}/resources/script/jquery.validate.js"></script>
<script type="text/javascript" src="${base}/resources/script/jquery.validate.methods.js"></script>
<script type="text/javascript">
$(function() {
	var $validateErrorContainer = $("#validateErrorContainer");
	var $validateErrorLabelContainer = $("#validateErrorContainer ul");
	var $validateForm = $("#validateForm");
	
	// 表单验证
	$validateForm.validate({
		errorContainer: $validateErrorContainer,
		errorLabelContainer: $validateErrorLabelContainer,
		wrapper: "li",
		errorClass: "validateError",
		ignoreTitle: true,
		rules: {
			"username": "required",
			"password": "required",
			"name": "required",
			"tel": "required",
			"address": "required",
			"email": "required",
			"ids": "required"
		},
		messages: {
			"username": "请填写用户名",
			"password": "请填写密码",
			"name": "请填写姓名",
			"tel": "请填写联系电话",
			"address": "请选择联系地址",
			"email": "请填写邮箱",
			"ids": "请设置用户角色"
		},
		submitHandler: function(form) {
			$(form).find(":submit").attr("disabled", true);
			form.submit();
		}
	});	
});

</script>
</@fn.header>
<body style="width:100%" class="list">
<form id="validateForm" action="<#if isAddAction>save<#else>update</#if>" method="post">
	<h2><img src="${base}/resources/style/images/iconDivM.gif" width="16" height="16" />用户管理</h2>
	<div id="validateErrorContainer" class="validateErrorContainer marginTop15" style="display:none;">
		<div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
		<ul></ul>
	</div>
	<div class="title marginTop15">
		<div class="title-middle">
			<div class="title-left"></div>
			<div class="title-caption"><#if isAddAction>添加用户<#else>编辑用户</#if></div>
            <div class="title-right"></div>
		</div>
	</div>
	<table class="table3" id="userListTable">
		<tr><th>用户名</th><td><input type="text" name="username" class="formText" value="${(user.username)!}" /> <label class="requireField">*</label></td></tr>
		<tr><th>密码</th><td><input type="password" name="password" class="formText" value="${(user.password)!}" /> <label class="requireField">*</label></td></tr>
		<tr><th>姓名</th><td><input type="text" name="name" class="formText" value="${(user.name)!}" /> <label class="requireField">*</label></td></tr>
		<tr><th>电话</th><td><input type="text" name="tel" class="formText" value="${(user.tel)!}" /> <label class="requireField">*</label></td></tr>
		<tr><th>地址</th><td><input type="text" name="address" class="formText" value="${(user.address)!}" /> <label class="requireField">*</label></td></tr>
		<tr><th>邮箱</th><td><input type="text" name="email" class="formText" value="${(user.email)!}" /> <label class="requireField">*</label></td></tr>
		<tr><th>所属角色</th><td><#list rolesList as role><input type="checkbox" name="ids" value="${role.id}"> ${role.name}&nbsp;&nbsp;</#list></td></tr>
		<tr><th>行政区域</th>
			<td>
				<select name="region.id">
					<option value="">请选择行政区域</option>
					<#list regionList as region>
					<option value="${region.id}">${region.name}</option>
					</#list>
				</select>
			</td>
		</tr>
		<tr><th>账号是否可用</th><td><select name="enabled"><option value="true">是</option><option value="false">否</option></select></td></tr>
		</tr>
	</table>
	<input type="submit" class="button" value="确 定" />
	<input type="button" class="button" value="返 回" onclick="javascript:history.go(-1);" />
</form>
</body>
</html>
